<?php

use think\migration\Migrator;
use think\migration\db\Column;

class BasicStation extends Migrator
{
    public function up()
    {
        $table = $this->table('basic_station');
        $table
            //step1:名称
            ->addColumn('station_id', 'integer', ['limit' => 6, 'comment'=>'站点ID'])
            ->addColumn('name', 'string', ['limit' => 50, 'default' => '', 'comment' => '站点名称'])
            ->addColumn('short_name', 'string', ['limit' => 50, 'default' => '', 'comment' => '站点名称-简称'])
            ->addColumn('region_id', 'integer', ['limit' => 6, 'comment'=>'所属区域ID'])
            ->addColumn('control_point', 'integer', ['limit' => 2, 'comment'=>'管控地点1国控点2省控点3市控点'])
            ->addColumn('delete_time', 'integer', ['limit' => 11, 'default' => 0, 'comment' => '软删除'])
            ->addColumn('longitude', 'string', ['limit' => 20, 'default' => '', 'comment' => '经度'])
            ->addColumn('latitude', 'string', ['limit' => 20, 'default' => '', 'comment' => '纬度'])

            //主键
            ->addIndex(['name'])

            //注释
            ->setComment('基本信息 - 站点名称')

            //引擎
            ->setEngine('InnoDB')
            ->save();
    }

    public function down()
    {
        $this->table('basic_station')->drop();
    }
}
